import { reqGetBaseCategoryList, reqGetBanners, reqGetFloors } from '@/api/home'
export default {
  namespaced: true,
  state: {
    // 首页三级分类菜单
    baseCategoryList: [],
    // 轮播图数据
    banners: [],
    // 家用电器数据
    floors: [],
  },
  actions: {
    async getBaseCategoryList({ commit }) {
      const baseCategoryList = await reqGetBaseCategoryList()
      commit('GET_BASE_CATEGORY_LIST', baseCategoryList.slice(0, -1))
    },
    async getBanners({ commit }) {
      const banners = await reqGetBanners()
      commit('GET_BANNERS', banners)
    },
    async getFloors({ commit }) {
      const floors = await reqGetFloors()
      commit('GET_FLOORS', floors)
    },
  },
  mutations: {
    // 三级分类菜单
    GET_BASE_CATEGORY_LIST(state, baseCategoryList) {
      state.baseCategoryList = baseCategoryList
    },
    // 轮播图
    GET_BANNERS(state, banners) {
      state.banners = banners
    },
    // 首页家用电梯栏
    GET_FLOORS(state, floors) {
      state.floors = floors
    },
  },
}
